home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: Hungarian notation
- Date: Thu, 18 Jan 1996 13:18:41 GMT
- Organization: Netcom
- Message-ID: <30fe433a.64663744@nntp.ix.netcom.com>
- References: <4dhkae$an9@blackice.winternet.com> <821890870snz@genesis.demon.co.uk> <30fd5306.3171520@nntp.ix.netcom.com> <9601181211.AA03705@dxmint.cern.ch>
- NNTP-Posting-Host: ix-dc8-24.ix.netcom.com
- X-NETCOM-Date: Thu Jan 18 5:18:27 AM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- Dan Pop <danpop@mail.cern.ch> wrote:
-
- > miker3@ix.netcom.com (Mike Rubenstein) writes:
- >
- > >There is one possibility that makes the cast to long double
- > >potentially dangerous according to the standard. There is no
- > >guarantee in the standard that all possible values of an integral type
- > >can be converted to long double.
- >
- > Such a guarantee actually exists.
- >
- > (ANSI classic) 3.2.1.5 Usual arithmetic conversions
- >
- > Many binary operators that expect operands of arithmetic type cause
- > conversions and yield result types in a similar way. The purpose is
- > to yield a common type, which is also the type of the result. This
- > pattern is called the usual arithmetic conversions: First, if either
- > operand has type long double, the other operand is converted to long
- > double.
- >
- > The last statement (sort of) guarantees that any arithmetic type can be
- > safely converted to long double, even if some information is lost in the
- > conversion (I'm typing this text on a machine where both long and long
- > double have the same size, hence some long values cannot be converted to
- > long double without loss of precision).
-
- I'm not sure I buy that as a guarantee, presumably for the same reason
- you added "(sort of)".
-
- #pragma talmudic
-
- In the same section, we find
-
- Otherwise, if either operand has type float, the other operand
-
- is converted to float.
-
- By your reasoning, this would guarantee that any integral type can be
- converted to float, possibly with loss of information. (The previous
- cases involve double and long double).
-
- But section 6.2.1.3 (ISO) says
-
- When a value of integral type is converted to floating type,
- if the value being converted is in the range of values that
- ***can be represented but*** cannot be represented exactly ...
- [emphasis added]
-
- If the intention is to require that the conversion be always possible,
- the words "can be resprented but" serve no useful purpose. 6.2.1.3
- (ISO) seems to indicate the possibility that there are values for some
- integral type that cannot be represented even inexactly in some
- floating point type.
-
- #pragma !talmudic
-
-
- Michael M Rubenstein
-